﻿#ifndef __AVOID_BW_CONTROL_DRAWH_HEAD_FILE_CINLULUDED__
#define __AVOID_BW_CONTROL_DRAWH_HEAD_FILE_CINLULUDED__
#include <Windows.h>
#include <GdiPlus.h>
#pragma comment(lib,"GdiPlus.lib")
#pragma comment(lib, "msimg32.lib")
using namespace Gdiplus;

#include "../../ctlStatic.h"
#include "../../ctlButton.h"
#include "../../ctlCheckBox.h"
#include "../../ctlRadioBox.h"
#include "../../ctlScroll.h"
#include "../../ctlEdit.h"
#include "../../ctlSingleEdit.h"
#include "../../ctlSingleLabel.h"
#include "../../ctlProgress.h"
#include "../../ctlList.h"
#include "../../ctlComboBox.h"
#include "../../ctlImageButton.h"

#define GETCOLOR_A(c)  ( (c) >> 24 )
#define GETCOLOR_R(c)  ( ((c) >> 16) & 0xff )
#define GETCOLOR_G(c)  ( ((c) >> 8) & 0xff )
#define GETCOLOR_B(c)  ( (c) & 0xff )

#define MAKE_COLOR32(c)  (Color(  \
	GETCOLOR_A(c), GETCOLOR_R(c), \
	GETCOLOR_G(c), GETCOLOR_B(c) )  )

#define MAKE_COLOR24(c)  (Color(  \
	255, GETCOLOR_R(c), GETCOLOR_G(c), GETCOLOR_B(c) )  )

#define MAKE_GRADIENT_BRUSH32(obj, c)    LinearGradientBrush obj(	\
	Point(0, top - 1), Point(0, bottom + 1),	MAKE_COLOR32((c).crBegin), MAKE_COLOR32((c).crEnd))

#define MAKE_GRADIENT_BRUSH32_H(obj, c)    LinearGradientBrush obj(	\
	Point(left - 1, 0), Point(right + 1, 0),	MAKE_COLOR32((c).crBegin), MAKE_COLOR32((c).crEnd))

#define MAKE_VERTEX(c, n)  {\
	(n)[0].Blue = GETCOLOR_B((c).crBegin) << 8 , (n)[1].Blue = GETCOLOR_B((c).crEnd) << 8;	\
	(n)[0].Red = GETCOLOR_R((c).crBegin) << 8 , (n)[1].Red = GETCOLOR_R((c).crEnd) << 8;	\
	(n)[0].Green = GETCOLOR_G((c).crBegin) << 8 , (n)[1].Green = GETCOLOR_G((c).crEnd) << 8;	\
	(n)[0].Alpha = 0 , (n)[1].Alpha = 0; }

#define MAKE_SYSTEM_RGB(c)	\
	(RGB(GETCOLOR_R(c), GETCOLOR_G(c), GETCOLOR_B(c)))

#define FORMAT_TEXT_ALIGN	\
		LONG format = DT_CENTER;\
		if(getTextAlignMode() == textAlign::left) format = DT_LEFT;\
		else if(getTextAlignMode() == textAlign::right) format = DT_RIGHT;

Status GdiPlusAddRoundRect(GraphicsPath& path, INT x, INT y, INT cx, INT cy, INT d);
Status GdiPlusAddRoundRect(GraphicsPath& path, INT x, INT y, INT cx, INT cy, INT d, INT w);
Status GdiPlusFillRoundRect(Graphics& graphics, Brush*brush, INT x, INT y, INT cx, INT cy, INT d, INT w);
Status GdiPlusDrawRoundRect(Graphics& graphics, Pen*pen, INT x, INT y, INT cx, INT cy, INT d, INT w);
Status GdiPlusFillRoundRect(Graphics& graphics, Brush*brush, INT x, INT y, INT cx, INT cy, INT d);
Status GdiPlusDrawRoundRect(Graphics& graphics, Pen*pen, INT x, INT y, INT cx, INT cy, INT d);
namespace swui
{
	void draw_image(ctlRect rect, _ctlInterior::drawInfo* info, std::shared_ptr<ctlImage> image,
		ctlImageRepeat repeat, unsigned char alpha, bool mask, ctlColor maskColor,
		_ctlInterior::tempAlphaDC& alphaDC);
}

#endif